package cn.iocoder.yudao.module.shop.info.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.shop.info.dal.dataobject.ShopEnterPackageDO;
import cn.iocoder.yudao.module.shop.info.service.ShopEnterPackageService;
import cn.iocoder.yudao.module.shop.info.vo.AppShopEnterPackageRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 App - 店铺套餐")
@RestController
@RequestMapping("/shop/enter-package")
@Validated
public class AppShopEnterPackageController {

    @Resource
    private ShopEnterPackageService shopEnterPackageService;

    @GetMapping("/top1")
    @Operation(summary = "获得一个套餐")
    @PermitAll
    public CommonResult<AppShopEnterPackageRespVO> getOne() {
        ShopEnterPackageDO aDo = shopEnterPackageService.getOne();
        return success(BeanUtils.toBean(aDo, AppShopEnterPackageRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得套餐列表")
    @PermitAll
    public CommonResult<List<AppShopEnterPackageRespVO>> getList() {
        List<ShopEnterPackageDO> pageResult = shopEnterPackageService.getList();
        return success(BeanUtils.toBean(pageResult, AppShopEnterPackageRespVO.class));
    }

}
